<!DOCTYPE html>
<html>
    <head>
        <!-- 页面meta -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>医疗管家</title>
        <meta name="description" content="医疗管家">
        <meta name="keywords" content="医疗管家">
        <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
        <!-- 引入样式 -->
        <link rel="stylesheet" href="../plugins/elementui/index.css">
        <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
        <link rel="stylesheet" href="../css/style.css">
        <!-- 引入组件库 -->
        <script type="text/javascript" src="../js/jquery.min.js"></script>
        <script src="../js/vue.js"></script>
        <script src="../plugins/elementui/index.js"></script>
        <script src="../js/axios-0.18.0.js"></script>
        <style>
            .avatar-uploader .el-upload {
                border: 1px dashed #d9d9d9;
                border-radius: 6px;
                cursor: pointer;
                position: relative;
                overflow: hidden;
            }
            .avatar-uploader .el-upload:hover {
                border-color: #409EFF;
            }
            .avatar-uploader-icon {
                font-size: 28px;
                color: #8c939d;
                width: 178px;
                height: 178px;
                line-height: 178px;
                text-align: center;
            }
            .avatar {
                width: 178px;
                height: 178px;
                display: block;
            }
            .datatable {
                position: relative;
                box-sizing: border-box;
                -webkit-box-flex: 1;
                width: 100%;
                max-width: 100%;
                font-size: 14px;
                color: rgb(96, 98, 102);
                overflow: hidden;
                flex: 1 1 0%;
            }
            .datatable td, .datatable th {
                padding: 12px 0;
                min-width: 0;
                -webkit-box-sizing: border-box;
                box-sizing: border-box;
                text-overflow: ellipsis;
                vertical-align: middle;
                position: relative;
                text-align: left;
            }
        </style>
    </head>
    <body class="hold-transition">
        <div id="app">
            <div class="content-header">
                <h1>预约管理<small>预约信息列表</small></h1>
                <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
                    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item>预约管理</el-breadcrumb-item>
                    <el-breadcrumb-item>预约信息列表</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="app-container">
                <div class="box">
                    <div class="filter-container">
                        <el-input placeholder="手机号码" v-model="pagination.queryString" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                        <el-button @click="findPage()" type="success" class="dalfBut">查询</el-button>
                        <el-button type="primary" class="butT" @click="selectOrderListByWeek()">本周的预约</el-button>
                        <el-button type="primary" class="butT" @click="selectOrderListByMonth()">本月的预约</el-button>
                    </div>
                    <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                        <el-table-column type="index" align="center" label="序号"></el-table-column>
                        <el-table-column prop="setmealName" label="套餐名称" align="center"></el-table-column>
                        <el-table-column prop="memberName" label="姓名" align="center"></el-table-column>
                        <el-table-column prop="phoneNumber" label="电话" align="center"></el-table-column>
                        <el-table-column prop="idCard" label="身份证号" align="center"></el-table-column>
                        <el-table-column prop="orderDate" label="预约时间" align="center"></el-table-column>
                        <el-table-column prop="orderStatus" label="状态" align="center"></el-table-column>
                        <el-table-column label="操作" align="center">
                            <template slot-scope="scope">
                                <el-button  type="primary" size="mini" @click="handleHasVisited(scope.row)">{{orderStatus}}</el-button>
<!--                                <el-button v-else type="primary" size="mini">已到诊</el-button>-->
                                <el-button size="mini" type="danger" @click="handleInfo(scope.row)">详情</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <div class="pagination-container">
                        <el-pagination
                            class="pagiantion"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.currentPage"
                            :page-size="pagination.pageSize"
                            layout="total, prev, pager, next, jumper"
                            :total="pagination.total">
                        </el-pagination>
                    </div>
                </div>
            </div>
        </div>
 </body>
    <script>
        var vue = new Vue({
            el: '#app',
            data:{
                pagination: {//分页相关属性
                    currentPage: 1,
                    pageSize:10,
                    total:100,
                    queryString:null,
                },
                orderStatus: "已到诊",
                dataList: [],//列表数据
            },
            created() {
                this.listPage();
            },
            methods: {
                handleHasVisited(row){
                    axios.put(`http://localhost:9002/order/update/${row.orderId}`).then(response=>{
                        console.log(response.data);
                        if (response.data.flag){
                            this.$message.success(response.data.message);
                        }
                        this.$message.error(response.data.message);
                    });
                    this.listPage();
                },
                handleInfo(row){
                    let memberId = row.memberId;
                    location.href="orderlistdetail.html?id=" + memberId;
                },
                selectOrderListByWeek(){
                    axios.post("http://localhost:9002/order/listByWeek",this.pagination).then(response=>{
                        this.pagination.total = response.data.total;
                        this.dataList = response.data.rows;
                    });
                },
                selectOrderListByMonth(){
                    axios.post("http://localhost:9002/order/listByMonth",this.pagination).then(response=>{
                        this.pagination.total = response.data.total;
                        this.dataList = response.data.rows;
                    });
                },
                listPage(){
                    axios.post("http://localhost:9002/order/list",this.pagination).then(response=>{
                        this.pagination.total = response.data.total;
                        this.dataList = response.data.rows;
                        // console.log(this.dataList);
                    });
                },
                //分页查询
                findPage() {
                    this.listPage();
                },
                //切换页码
                handleCurrentChange(currentPage) {
                    this.pagination.currentPage = currentPage;
                    this.listPage();
                },
            }
        })
    </script>
</html>
